package org.teamswift.crow.rbac.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.stereotype.Repository;
import org.teamswift.crow.rbac.entity.CrowUserRole;

import java.util.Collection;
import java.util.List;

@Repository
public interface CrowUserRoleRepository extends JpaRepository<CrowUserRole, Integer>, JpaSpecificationExecutor<CrowUserRole> {

    List<CrowUserRole> findAllByUserIdAndOrgId(Integer userId, Integer companyId);

    List<CrowUserRole> findAllByUserIdIn(Collection<Integer> userId);

    List<CrowUserRole> findAllByUserIdInAndOrgId(List<Integer> ids, Integer companyId);

    List<CrowUserRole> findAllByUserId(Integer id);

    @Modifying
    void deleteAllByUserIdAndOrgId(Integer userId, Integer companyId);

}
